package com.baizhi.usercloud.controller;


import com.baizhi.usercloud.FeignProductService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private FeignProductService feignProductService;
    @GetMapping("selectAll")
    @HystrixCommand(fallbackMethod = "getHystrixInfo")//需要熔断的方法上面添加hystrix注解
    public String selectAll() {
        String s=feignProductService.selectAll();
        return "这是用户查询所有的方法%%%8085"+s;
    }
    //这个方法是一个回退方法，请求参数和返回值应该跟请求地址对应的方法的参数和返回值一致
    public String getHystrixInfo(){
        return "熔断错误，稍后重试";
    }
}
